const { contextBridge, ipcRenderer } = require('electron')

contextBridge.exposeInMainWorld('electronAPI', {
    // win 
    setWindowMin: () => ipcRenderer.send('ipc:set-window-min'),
    setWindowMax: () => ipcRenderer.send('ipc:set-window-max'),
    setWindowExit: () => ipcRenderer.send('ipc:set-window-exit'),

    // url
    openUrl: (url) => ipcRenderer.invoke('ipc:open-url', url),

    // config
    getConfigs: () => ipcRenderer.invoke('ipc:get-configs'),
    setConfigs: (config, value) => ipcRenderer.invoke('ipc:set-configs', config, value),

    // serial
    getSerials: () => ipcRenderer.invoke('ipc:get-serials'),
    setSerials: (serial) => ipcRenderer.invoke('ipc:set-serials', serial),

    // net
    setNets: (net) => ipcRenderer.invoke('ipc:set-nets', net),

    // message
    sendMessages: (message) => ipcRenderer.invoke('ipc:send-messages', message),
    recvMessages: (callback) => ipcRenderer.on('ipc:recv-messages', callback),
})